<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul class="nav">
        <a href="#"> 微博</a>
        <ul>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </ul>
    <script>
        // 1.导航栏里的li都要有鼠标经过效果，所以需要循环注册鼠标事件
        // 2.核心原理：当鼠标经过li里面的第二个孩子ul显示，当鼠标离开则ul隐藏
        var nav = document.querySelector('.nav');
        var lis = nav.children;
        for (var i; i < lis.length; i++) {
            lis[i].onmouseover = function () {
                this.children[1].style.display = 'block';
            }

            lis[i].onmouseout = function () {
                this.children[1].style.display = 'none';
            }
        }

        function getNextElementSibling(element) {
            var el = element;
            while (el = el.nextSibling) {
                if (el.nodeType === 1) {
                    return el;
                }
            }
            return null;
        }
    </script>
</body>

</html>